package android_fields;

import static android_board.GUIBoard.FIELDHEIGHT;
import static android_board.GUIBoard.FIELDWIDTH;

import common.GUIColor;

import android.view.View;
import android.widget.RelativeLayout;
import android_board.GUICenter;
import dk.dtu.compute.course02312.matadorfinal.MainActivity;
import dk.dtu.compute.course02312.matadorfinal.R;

public final class GUITax extends AndroidField {
//	private static final float IMAGEHEIGHTPART = 0.00f;
	private static final float TITLEHEIGHTPART = 0.79f;
//	private static final float SUBTEXTHEIGHTPART = 0.19f;

	public static class Builder extends AndroidField.Builder<GUITax.Builder> implements
			iBuilder {
		public Builder() {
			this.title = "Tax";
			this.bgColor = new GUIColor(MainActivity.context.getResources()
					.getColor(R.color.taxbg));
		}

		@Override
		@SuppressWarnings("synthetic-access")
		public final GUITax build() {
			return new GUITax(this.title, this.subText, this.description,
					this.bgColor, this.fgColor);
		}

		public final Builder setDescription(String description) {
			this.description = description;
			return this;
		}

		public final Builder setTitle(String title) {
			this.title = title;
			return this;
		}

		public final Builder setSubText(String subText) {
			this.subText = subText;
			return this;
		}
	}

	private GUITax(String title, String subText, String description,
			GUIColor bgColor, GUIColor fgColor) {
		super(bgColor, fgColor, title, subText, description);
		this.titleView.setText(this.title);
		int height = (int) (TITLEHEIGHTPART * FIELDHEIGHT);
		RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(
				FIELDWIDTH, height);
		this.subTextView.setText(this.subText);
		this.cell.addView(this.titleView, titleParams);
	}

	@Override
	public void displayOnCenter() {
		super.displayOnCenter();
		GUICenter.textViews[1].setText(this.description);
		GUICenter.textViews[1].setVisibility(View.VISIBLE);
		super.displayCarOnCenter();
	}
}
